/*
 * jBar Progress Bar plugin
 * JavaScript progress bar plugin for jQuery JavaScript Library.
 * http://code.google.com/p/progbar/
 * Version 0.1 alpha (unreleased)
 * Requires: jQuery v1.3.2 or later
 *
 * Copyright (c) 2010 M. van Driel
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function($){
	$.extend($.fn, {
		jbar: function(options) {
		
			var defaults = {
				css {
					width: "160px",
					height: "24px",
					background: '#fff',
					border: '1px solid #555'
					progbackground: '#156220'
				}
			};
			
			var opts = $.extend(defaults, options);

			var min = 0;
			var max = 0;
			var progress = 0;
			var value = this.text();
			
			var html_settings = {
				progWidth: 0,
				progBackground: opts.css.progbackground
			};

			var charpos = value.indexOf("%");
			if (charpos >= 0) {
				progress = parseInt(value);
				max = 100;
				html_settings.progWidth = progress + "%";
			}
			
			var progDisp = progress + "/" + max;
			
			
			this
				.html("<div class='jbar-progress'>" + progDisp  + "</div>")
				.find(".jbar-progress").css({
					width: html_settings.progWidth
				});
			
			this.css({
				width: opts.css.width,
				height: opts.css.height,
				background: opts.css.background,
				border: opts.css.border
			});
		}
	});
})(jQuery);